﻿using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using T.ApiResults;
using T.ApprovalRecord;
using T.Personnel.API.Application.Command.ApprovalCommand;

namespace T.Personnel.API.Controllers
{
    /// <summary>
    /// 人事审批
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class ApprovalController : ControllerBase
    {
        private readonly IMediator mediator;

        public ApprovalController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 添加入职审批表
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddEntryApprovalAsync(AddEntryApprovalCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 添加转正审批表
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddFullApprovalAsync(AddFullApprovalCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 添加离职审批表
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddResignationApprovalAsync(AddResignationCommand command)
        {
            return await mediator.Send(command);
        }
    }
}
